

/*流量来源级联  begin*/

function removeCHRSourceTwo(){
		  $("#chrSourceTwo_mu").empty();
		  $("#chrSourceThree_mu").empty();
		  $("#chrSourceFour_mu").empty();
		  
		  $("#chrSourceTwo_mu").selectpicker('refresh');
		  $("#chrSourceThree_mu").selectpicker('refresh');
		  $("#chrSourceFour_mu").selectpicker('refresh');
		  
		  $("#chrSourceTwo").val('');
		  $("#chrSourceThree").val('');
		  $("#chrSourceFour").val('');
}


function removeCHRSourceThree(){
	
		  $("#chrSourceThree_mu").empty();
		  $("#chrSourceFour_mu").empty();
		  
		  $("#chrSourceThree_mu").selectpicker('refresh');
		  $("#chrSourceFour_mu").selectpicker('refresh');
		  
		  $("#chrSourceThree").val('');
		  $("#chrSourceFour").val('');
		  
}


function removeCHRSourceFour(){
	
		  $("#chrSourceFour_mu").empty();
		  
		  $("#chrSourceFour_mu").selectpicker('refresh');
		  
		  $("#chrSourceFour").val('');
		  
}



function changeCHRSourceTwo(source1){
	if(source1 != "" ){
      	jQuery.ajax({
        type:"post",
        dataType:"json",
        async:true,
        url:"/irtools/chrflowsourcesearch",
        data:{"source1":source1,"pathId":$("#pathId").val()},
        success:function(data){
           if(data!="" && data.result =="right"){
              	var sourceTwoList = "";
              	$.each(data.chrSourceTwoList, function(i, obj) {
                sourceTwoList = sourceTwoList + "<option value='"+obj.source2+"' title='"+obj.source2_name+"'>"+obj.source2_name+"</option>";
             });
             $("#chrSourceTwo_mu").empty().append(sourceTwoList);
			 $("#chrSourceTwo_mu").selectpicker('refresh');
			 $("#chrSourceTwo").val('');
			 removeCHRSourceThree();
           }else{
		   	  alert("error!");
		   }
        }
   	  });
     }else{
	 	 removeCHRSourceTwo();
	 }
}

function changeCHRSourceThree(source1,source2){
	var strSource1 = String(source1);
	var strSource2 = String(source2);
	
	if(strSource1 != "" && source2 != ""){
      	jQuery.ajax({
       		type:"post",
        	dataType:"json",
        	async:true,
        	url:"/irtools/chrflowsourcesearch",
        	data:{"source1":strSource1,"source2":strSource2,"pathId":$("#pathId").val()},
        	success:function(data){
           	if(data!="" && data.result =="right"){
              	var sourceThreeList = "";
              	$.each(data.chrSourceThreeList, function(i, obj) {
              		sourceThreeList = sourceThreeList + "<option value='"+obj.source3+"' title='"+obj.source3_name+"'>"+obj.source3_name+"</option>";
              	});
             	$("#chrSourceThree_mu").empty().append(sourceThreeList);
			 	$("#chrSourceThree_mu").selectpicker('refresh');
			 	$("#chrSourceThree").val('');
           	}else{
		   	  	alert("error!");
		   	}
        }
   	  });
     }else{
		removeCHRSourceThree();
	 }
}



function changeCHRSourceFour(source1,source2,source3){
	var strSource1 = String(source1);
	var strSource2 = String(source2);
	var strSource3 = String(source3);
	
	if(strSource1 != "" && source2 != "" && source3 != "" ){
      	jQuery.ajax({
       		type:"post",
        	dataType:"json",
        	async:true,
        	url:"/irtools/chrflowsourcesearch",
        	data:{"source1":strSource1,"source2":strSource2,"source3":strSource3,"pathId":$("#pathId").val()},
        	success:function(data){
           	if(data!="" && data.result =="right"){
              	var sourceFourList = "";
              	$.each(data.chrSourceFourList, function(i, obj) {
              		sourceFourList = sourceFourList + "<option value='"+obj.source4+"' title='"+obj.source4_name+"'>"+obj.source4_name+"</option>";
              	});
             	$("#chrSourceFour_mu").empty().append(sourceFourList);
			 	$("#chrSourceFour_mu").selectpicker('refresh');
			 	$("#chrSourceFour").val('');
           	}else{
		   	  	alert("error!");
		   	}
        }
   	  });
     }else{
		removeCHRSourceFour();
	 }
}




/*行业级联  begin*/

function changeCHRIndustry1(type,chrIndustryOne){
	var chrIndustryOneVal = String(chrIndustryOne);
	if(type == 'add' && chrIndustryOneVal != ""){
      	jQuery.ajax({
        type:"post",
        dataType:"json",
        async:true,
        url:"/irtools/chrindustrysearch",
        data:{"cate1_name":chrIndustryOneVal},
        success:function(data){
           if(data!="" && data.result =="right"){
          	  var industryTwoList = '';
              $.each(data.chrIndustryTwoList, function(i, obj) {
                 industryTwoList = industryTwoList + "<option value='"+obj.cate2_name+"' title='"+obj.cate2_name+"'>"+obj.cate2_name+"</option>";
              });
              $("#chrIndustryTwo_mu").empty().append(industryTwoList);
              $("#chrIndustryTwo_mu").selectpicker('refresh');
              $("#chrIndustryTwo").val('');
           }else{
		   	  alert("error!");
		   }
        }
   	  });
	}else if(type == 'remove'){
		$("#chrIndustryTwo_mu").empty();
		$("#chrIndustryTwo").val('');
		$("#chrIndustryTwo_mu").selectpicker('refresh');
	}
}

/*JOB级联  begin*/

function removeCHRJobTwo(){
		  $("#chrJobTwo_mu").empty();
		  $("#chrJobThree_mu").empty();
		  
		  $("#chrJobTwo_mu").selectpicker('refresh');
		  $("#chrJobThree_mu").selectpicker('refresh');
		  
		  $("#chrJobTwo").val('');
		  $("#chrJobThree").val('');
}


function removeCHRJobThree(){
		  $("#chrJobThree_mu").empty();
		  
		  $("#chrJobThree_mu").selectpicker('refresh');
		  
		  $("#chrJobThree").val('');
}






function changeCHRJobTwo(cate1){
	if(cate1 != "" ){
      	jQuery.ajax({
        type:"post",
        dataType:"json",
        async:true,
        url:"/irtools/chrjobsearch",
        data:{"cate1_name":cate1},
        success:function(data){
           if(data!="" && data.result =="right"){
              	var jobTwoList = "";
              	$.each(data.chrJobTwoList, function(i, obj) {
                jobTwoList = jobTwoList + "<option value='"+obj.cate2_name+"' title='"+obj.cate2_name+"'>"+obj.cate2_name+"</option>";
             });
             $("#chrJobTwo_mu").empty().append(jobTwoList);
			 $("#chrJobTwo_mu").selectpicker('refresh');
			 $("#chrJobTwo").val('');
			 removeCHRJobThree();
           }else{
		   	  alert("error!");
		   }
        }
   	  });
     }else{
	 	 removeCHRJobTwo();
	 }
}

function changeCHRJobThree(cate1,cate2){
	var strCate1 = String(cate1);
	var strCate2 = String(cate2);
	
	if(strCate1 != "" && strCate2 != ""){
      	jQuery.ajax({
       		type:"post",
        	dataType:"json",
        	async:true,
        	url:"/irtools/chrjobsearch",
        	data:{"cate1_name":strCate1,"cate2_name":strCate2},
        	success:function(data){
           	if(data!="" && data.result =="right"){
              	var jobThreeList = "";
              	$.each(data.chrJobThreeList, function(i, obj) {
              		jobThreeList = jobThreeList + "<option value='"+obj.cate3_name+"' title='"+obj.cate3_name+"'>"+obj.cate3_name+"</option>";
              	});
             	$("#chrJobThree_mu").empty().append(jobThreeList);
			 	$("#chrJobThree_mu").selectpicker('refresh');
			 	$("#chrJobThree").val('');
           	}else{
		   	  	alert("error!");
		   	}
        }
   	  });
     }else{
		removeCHRJobThree();
	 }
}

 /**中华职位行业控件**/
  $("select[compType='chrjob']").on('change', function(){
    var selectName=$(this).attr('name');
    var selectLevel=parseInt($(this).attr('level'));
    if(selectLevel==1){
            var selected = $(this).find("option:selected").val();
               if(document.getElementById('chrJobTwo_mu')!=undefined)
               {
                     if((selected!=undefined)&&($('#'+selectName).val()!=null)&&($('#'+selectName).val().length==1))
                    {
                       changeCHRJobTwo(selected);
                    }else
                    {
                       removeCHRJobTwo();
                    }
              }
              if($('#'+selectName).val()!=null)
                {
                    setSelectValue($(this).val(),'chrJobOne');
                }else{
                $('#chrJobOne').val("");
               }

    }else if(selectLevel==2)
    {
           var selected = $(this).find("option:selected").val();
               if(document.getElementById('chrJobThree_mu')!=undefined)
               {
                     if((selected!=undefined)&&($('#'+selectName).val()!=null)&&($('#'+selectName).val().length==1))
                    {
                       changeCHRJobThree($("#chrJobOne_mu").val(),selected);
                    }else
                    {
                       removeCHRJobThree();
                    }
              }
              if($('#'+selectName).val()!=null)
                {
                    setSelectValue($(this).val(),'chrJobTwo');
                }else{
                $('#chrJobTwo').val("");
               }
     
    }else if(selectLevel==3)
    {
         if($('#'+selectName).val()!=null)
          {
            setSelectValue($(this).val(),'chrJobThree');
          }else
          {
            $('#chrJobThree').val("");
          }
    }     
 });
  /**中华英才行业控件**/
  $("select[compType='chrindustry']").on('change', function(){
    var selectName=$(this).attr('name');
    var selectLevel=parseInt($(this).attr('level'));
    if(selectLevel==1){
        var selected = $(this).find("option:selected").val();
               if(document.getElementById('chrIndustryTwo_mu')!=undefined)
               {
                     if((selected!=undefined)&&($('#'+selectName).val()!=null)&&($('#'+selectName).val().length==1))
                    {
                       changeCHRIndustry1('add',selected);
                    }else
                    {
                       changeCHRIndustry1("remove");
                    }
              }
              if($('#'+selectName).val()!=null)
                {
                    setSelectValue($(this).val(),'chrIndustryOne');
                }else{
                $('#chrIndustryOne').val("");
               }

    }else if(selectLevel==2)
    {
           if($('#'+selectName).val()!=null)
          {
            setSelectValue($(this).val(),'chrIndustryTwo');
          }else
          {
            $('#chrIndustryTwo').val("");
          }
     
    }
  });
  /**中华英才来源控件**/
  $("select[compType='chrsource']").on('change', function(){
    var selectName=$(this).attr('name');
    var selectLevel=parseInt($(this).attr('level'));
    if(selectLevel==1){
            var selected = $(this).find("option:selected").val();
               if(document.getElementById('chrSourceTwo_mu')!=undefined)
               {
                     if((selected!=undefined)&&($('#'+selectName).val()!=null)&&($('#'+selectName).val().length==1))
                    {
                       changeCHRSourceTwo(selected);
                    }else
                    {
                       removeCHRSourceTwo();
                    }
              }
              if($('#'+selectName).val()!=null)
                {
                    setSelectValue($(this).val(),'chrSourceOne');
                }else{
                $('#chrSourceOne').val("");
               }

    }else if(selectLevel==2)
    {
           var selected = $(this).find("option:selected").val();
               if(document.getElementById('chrSourceThree_mu')!=undefined)
               {
                     if((selected!=undefined)&&($('#'+selectName).val()!=null)&&($('#'+selectName).val().length==1))
                    {
                       changeCHRSourceThree($("#chrSourceOne_mu").val(),selected);
                    }else
                    {
                       removeCHRSourceThree();
                    }
              }
              if($('#'+selectName).val()!=null)
                {
                    setSelectValue($(this).val(),'chrSourceTwo');
                }else{
                $('#chrSourceTwo').val("");
               }
     
    }else if(selectLevel==3)
    {
         var selected = $(this).find("option:selected").val();
               if(document.getElementById('chrSourceFour_mu')!=undefined)
               {
                     if((selected!=undefined)&&($('#'+selectName).val()!=null)&&($('#'+selectName).val().length==1))
                    {
                       changeCHRSourceFour($("#chrSourceOne_mu").val(),$("#chrSourceTwo_mu").val(),selected);
                    }else
                    {
                       removeCHRSourceFour();
                    }
              }
              if($('#'+selectName).val()!=null)
                {
                    setSelectValue($(this).val(),'chrSourceThree');
                }else{
                $('#chrSourceThree').val("");
               }
    }else if(selectLevel==4)
    {
         if($('#'+selectName).val()!=null)
          {
            setSelectValue($(this).val(),'chrSourceFour');
          }else
          {
            $('#chrSourceFour').val("");
          }
    }     
 });

